import matplotlib.pyplot as plt
import random

# # 分别存放所有点的横坐标和纵坐标，一一对应
# x_list = [1, 2, 5]
# y_list = [3, 4, 9]
#
# # 创建图并命名
# plt.figure('Line fig')
# ax = plt.gca()
# # 设置x轴、y轴名称
# ax.set_xlabel('x')
# ax.set_ylabel('y')
#
# # 画连线图，以x_list中的值为横坐标，以y_list中的值为纵坐标
# # 参数c指定连线的颜色，linewidth指定连线宽度，alpha指定连线的透明度
# ax.plot(x_list, y_list, color='r', linewidth=1, alpha=0.6)
#
# plt.show()
# a = []
# for i in range(10):
#     a.append(random.randint(1, 100))
# print(a)
# b = a.copy()
# sum = sum(a)
# for ii in range(len(a)):
#     a[ii] = a[ii] / sum
# cumulateRate = []
# for ii in range(len(a)):
#     if ii == 0:
#         cumulateRate.append(a[0])
#     else:
#         temp_sum = 0
#         for jj in range(ii + 1):
#             temp_sum = temp_sum + a[jj]
#         cumulateRate.append(temp_sum)
# print(cumulateRate)
# # 开始轮盘赌选择
# chosen = []  # 存放被选中的个体
# for k in range(len(a)):
#     r = random.randint(0, 1000) / 1000
#     if r <= cumulateRate[0] and ((0 in chosen) is False):
#         chosen.append(0)
#     else:
#         for kk in range(len(a) - 1):
#             if (cumulateRate[kk] < r <= cumulateRate[kk + 1]) and ((kk + 1 in chosen) is False):
#                 chosen.append(kk + 1)
# print(chosen)
# for c in chosen:
#     print(b[c], end=' ')
# index = 0
# for j in range(len(a)):
#     if a[j] < a[index]:
#         index = j
# print(a[index])

list1 = [1, 23, 4, 5, 6, 8, 9]
list1[0], list1[5], list1[2] = list1[5], list1[2], list1[0]
print(list1)
list2 = [1, 4, 9, 16, 25, 36, 49, 64, 81]
plt.plot(range(9), list2, color='green', label='training accuracy')
plt.show()
